<template>
	<view class="parent">

		<view class="input-container">
			<view class="label"> 原密码 </view>
			<input class="et" placeholder="请输入原密码" v-model="form.oldPassWord" password/>
		</view>

		<view class="input-container">
			<view class="label"> 新密码 </view>
			<input class="et" placeholder="请输入新密码" v-model="form.passWord" password/>
		</view>
		
		<view class="input-container">
			<view class="label"> 再次密码 </view>
			<input class="et" placeholder="请输入再次密码" v-model="form.surepassword" password/>
		</view>
		
		<zy-button text="保存" @click.native="onRegister" style="margin-top: 100rpx"></zy-button>
	</view>
</template>

<script>
	import RouteUtil from '@/main/common/RouteUtil'
	export default {
		data() {
			return {
				form: {
					oldPassWord: '',
					passWord: '',
					surepassword: '',
				}
			}
		},
		methods: {
			async onRegister(){
				if(!this.form.oldPassWord){
					uni.$toast.showToast('请输入原密码')
					return
				}
				if(!this.form.passWord){
					uni.$toast.showToast('请输入新密码')
					return
				}
				if(this.form.passWord != this.form.surepassword){
					uni.$toast.showToast('两次密码不一致')
					return
				}
				
				uni.$http.post('/api/user/updateUserPassWord', this.form).then(res=>{
					uni.$toast.showToast('修改成功')
					RouteUtil.back()
				})
			},

		}
	}
</script>

<style lang="scss">
	.parent {
		background-color: #f5f5f5;
		height: 100vh;
		padding: 0 50rpx;
	}

	.input-container {
		display: flex;
		flex-direction: row;
		align-items: center;
		height: 90rpx;
		margin-top: 30rpx;
		background-color: #ededed;
		border-radius: 10rpx;
		
		.label {
			width: 150rpx;
			height: 100%;
			line-height: 90rpx;
			font-size: 36rpx;
			color: #222;
			text-align: center;
		}
		
		.et {
			height: 100%;
			line-height: 100rpx;
			padding: 0 20rpx;
			font-size: 28rpx;
			flex: 1;
		}
	}
	
</style>